
using System;
using foundation;
[AttributeUsage(AttributeTargets.Class)]
public sealed class ModelAttribute : Attribute
{
    public string name;
    public ModelAttribute(string name)
    {
        this.name = name;
    }

    public static void register(BaseModel model)
    {
        if (null == model) return;
        var type = typeof(ModelAttribute);
        var objType = model.GetType();
        var target = Attribute.GetCustomAttribute(objType, type) as ModelAttribute;
        if (null != target)
        {
            BaseModel.models.Add(target.name, model);
            model.key = target.name;
        }

    }
}